<h1>Lead Status</h1>

<?php
    $this->headTitle('Lead Status');
    $acl = $this->acl;
?>
<div class="clearing">
</div>
<?php

if ($acl->isAllowed($this->currentUser, 'access lead pages')):
    printf("<a href=\"%s\">Leads</a> ", 
        $this->url(
            array(
                'module' => 'default', 
                'controller' => 'lead'
            ), NULL , TRUE)
        );
endif;
?>
|
<?php if ($acl->isAllowed($this->currentUser, 'administer leads')): ?>
    <a class="icon" href="<?php echo $this->url(
        array(
            'module' => 'lead', 
            'controller' => 'settings', 
            'action' => 'index'
        ), null, true
                        ); ?>">
        <!--<img style="margin-bottom:0px;margin-right:0px;" 
            src="/images/design/lead_settings.png" border="0"/> -->
 <span>Lead settings</span></a>
<?php endif; ?>
|
<a href="<?php echo $this->url(array(
        'module'        => 'default',
        'controller'    => 'leadstatus',
        'action'        => 'create'
        )); ?>">Create lead status</a>

<br />

<?php
    echo $this->form;
?>
<div class="clearing">
</div>
<?php $paginator = ( $this->paginator); ?>
<?php
    $allowedKeys = array('name', 'description');
?>

<?php
 if (count($this->paginator)):
?>


<table class="data_table">
    <tr>
        <th class="short">Name<?php echo $this->sortButtons("name"); ?></th>
        <th class="short">Description</th>
        <th class="short">Action</th>
    </tr>


<?php foreach ($paginator as $item): ?>

<?php
        $itemArray = $item->toArray();
?>
    <tr>
    <?php
        foreach ($itemArray as $key=>$value) {
            if ($key == 'lead_status_id') {
                $lead_status_id = $this->escape($value);
            } 
            if (in_array($key, $allowedKeys)) {
                    echo "<td>" .  $this->escape($value) . "</td>";
                }
            }
     ?>     
            <td>
               <a href="<?php 
                    echo $this->url(array(
                        'module'        =>  'default', 
                        'controller'    =>  'leadstatus', 
                        'action'        =>  'viewdetails', 
                        'lead_status_id'    =>  $lead_status_id,
                    ));                    
                  ?>">
                        <span>View</span>
                </a>
                &nbsp;
                <a href="<?php 
                    echo $this->url(array(
                        'module'        =>  'default', 
                        'controller'    =>  'leadstatus', 
                        'action'        =>  'edit', 
                        'lead_status_id'    =>  $lead_status_id,
                    )); 
             ?>">
                <span>Edit</span>
                </a>

            </td>

    </tr>
<?php endforeach; ?>
    </table>

<div class="pagination">
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'search.phtml'); ?>
</div>
<div class="div_clear"></div>

<?php endif; ?>

<?php
        if ($this->wasSearched and !count($this->paginator)) {
            echo "<br />There are no records matching the search criteria";
        }
?>

